'This function checks a windows user password whether it is valid and matching to the given username.

Private Declare Auto Function LogonUser Lib "advapi32.dll" ( _
    ByVal lpszUsername As String, _
    ByVal lpszDomain As String, _
    ByVal lpszPassword As String, _
    ByVal dwLogonType As LogonType, _
    ByVal dwLogonProvider As Integer, _
    ByRef phToken As IntPtr) _
As Integer

Private Declare Auto Function CloseHandle Lib "kernel32.dll" ( _
    ByVal hObject As IntPtr) _
As Boolean

Public Enum LogonType As Integer
    LOGON32_LOGON_INTERACTIVE = 2
    LOGON32_LOGON_NETWORK = 3
    LOGON32_LOGON_BATCH = 4
    LOGON32_LOGON_SERVICE = 5
    LOGON32_LOGON_UNLOCK = 7
    LOGON32_LOGON_NETWORK_CLEARTEXT = 8
    LOGON32_LOGON_NEW_CREDENTIALS = 9
End Enum

Public Function IsNTPasswordValid(ByVal Username As String, ByVal Password As String, Optional ByVal Domain As String = "") As Boolean
    Dim Token As New IntPtr
    LogonUser(Username, Domain, Password, LogonType.LOGON32_LOGON_INTERACTIVE, 0, Token)
    CloseHandle(Token)
    If Token.ToInt32 <> 0 Then Return True
End Function